package com.chen.common;

import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

/**
 * @Description
 * @Author Pengwei
 * @CreatDate 2021/11/17 10:30
 */
@Data
@Accessors(chain = true)
public class Result<T> {

    private static String okCode = PropertiesUtil.get("net.code.ok");
    private static String okMsg = Lang.get("net.code.ok.msg");
    private static String errorCode = PropertiesUtil.get("net.code.error");
    private static String errorMsg = Lang.get("net.code.error.msg");

    private String code;
    private String msg;
    private T data;

    private Result() {
    }

    public static <T> Result ok() {
        return new Result<T>().setCode(okCode).setMsg(okMsg);
    }

    public Result<T> error() {
        return new Result<T>().setCode(errorCode).setMsg(errorMsg);
    }

    public Boolean isOk() {
        return okCode.equals(this.code);
    }
}
